local kuangfeng = fk.CreateSkill {

  name = "joy__kuangfeng",

  tags = {  },

}



kuangfeng:addEffect(fk.EventPhaseEnd, {
  name = "joy__kuangfeng",
  events = {fk.EventPhaseEnd},
  anim_type = "offensive",
  expand_pile = "star",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(kuangfeng.name) then return false end
      return target == player and player.phase == Player.Play and #player:getPile("star") > 0
  end,
  on_cost = function(self, event, target, player, data)
      local room = player.room
      local targets = room:askForChoosePlayers(player, table.map(room.alive_players, Util.IdMapper), 1, #room.alive_players, "#joy__kuangfeng-target", kuangfeng.name,true)
      if #targets > 0 then
        local cids = room:askForCard(player, #targets, #targets, false, kuangfeng.name, true, ".|.|.|star", "#joy__kuangfeng-card:::"..#targets, "star")
        if #cids > 0 then
          event:setCostData(self, {targets, cids})
          return true
        end
      end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:moveCardTo(event:getCostData(self)[2], Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, kuangfeng.name, "star")
    for _, id in ipairs(event:getCostData(self)[1]) do
      local p = room:getPlayerById(id)
      if not p.dead then
        room:damage{from = player, to = p, damage = 1, skillName = kuangfeng.name}
      end
    end
  end,
})

return kuangfeng